// 人员相关配置

import axios from 'axios'
import {nanoid} from 'nanoid'
export default {
  namespaced: true,
  state:{
    personList:[
      {id:'001',name:'张三'}
    ]
  },
  actions:{
    addWangPerson(context,person){
      if(person.name.indexOf('王')===0){
        context.commit('ADDPERSON',person)
      }
    },
    addPersonServe(context){
      axios.get('https://api.uixsj.cn/hitokoto/get?type=social').then(
        response=>{
          context.commit('ADDPERSON',{id:nanoid(),name:response.data})
        },
        error=>{
          alert(error.message)
        }
      )
    }
  },
  mutations:{
    ADDPERSON(state,person){
      state.personList.unshift(person)
    }
  },
  getters:{},
}